package com.sfac.javaSpringBoot.modules.test.controller;


import com.sfac.javaSpringBoot.modules.test.entity.Country;
import com.sfac.javaSpringBoot.modules.test.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class CountryController {
    @Autowired
    private CountryService countryService;

    /**
     * 127.0.0.1:8080/api/country/522 ---- get
     */
    @GetMapping("/country/{countryId}")
    public Country getCitiesByCountryId(@PathVariable int countryId) {
        return countryService.getCountryByCountryId(countryId);
    }

    /**
     * 127.0.0.1:8080/api/country?countryName=China&localCountryName=Zhongquo ---- get
     */
    @GetMapping("/country")
    public Country getCountryByCountryName(@RequestParam String countryName,
                                           @RequestParam String localCountryName) {
        return countryService.getCountryByCountryName(countryName, localCountryName);
    }


}
